﻿CREATE TABLE [dbo].[ConcediiMedicale] (
    [IdCM]                  INT             IDENTITY (1, 1) NOT NULL,
    [IdPersoana]            INT             CONSTRAINT [DF_ConcediiMedicale_IdAngajat] DEFAULT ((0)) NOT NULL,
    [NumarCM]               VARCHAR (10)    CONSTRAINT [DF_ConcediiMedicale_NumarCM] DEFAULT ('') NOT NULL,
    [SerieCM]               VARCHAR (10)    CONSTRAINT [DF_ConcediiMedicale_SerieCM] DEFAULT ('') NOT NULL,
    [DataCM]                DATETIME        CONSTRAINT [DF_ConcediiMedicale_DataCM] DEFAULT (getdate()) NOT NULL,
    [DataInceput]           DATETIME        CONSTRAINT [DF_ConcediiMedicale_DataInceput] DEFAULT (getdate()) NOT NULL,
    [DataSfarsit]           DATETIME        CONSTRAINT [DF_ConcediiMedicale_DataSfarsit] DEFAULT (getdate()) NOT NULL,
    [ZileBoala]             INT             CONSTRAINT [DF_ConcediiMedicale_ZileCMCalculate] DEFAULT ((0)) NOT NULL,
    [IdCMContinuare]        INT             CONSTRAINT [DF_ConcediiMedicale_IdCMContinuare] DEFAULT ((0)) NULL,
    [SumaCM]                DECIMAL (18, 2) CONSTRAINT [DF_ConcediiMedicale_SumaCM] DEFAULT ((0)) NOT NULL,
    [BazaCM]                DECIMAL (18, 5) CONSTRAINT [DF_ConcediiMedicale_BazaCM] DEFAULT ((0)) NOT NULL,
    [IdDepartament]         INT             CONSTRAINT [DF_ConcediiMedicale_IdDepartament] DEFAULT ((0)) NOT NULL,
    [CodUrgenta]            VARCHAR (20)    NULL,
    [CodBoala]              VARCHAR (20)    NULL,
    [CodDiagnostic]         VARCHAR (20)    NULL,
    [ZileCAS]               INT             CONSTRAINT [DF_ConcediiMedicale_ZileCAS] DEFAULT ((0)) NOT NULL,
    [ZileBoalaCumulate]     INT             CONSTRAINT [DF_ConcediiMedicale_ZileBoalaCumulate] DEFAULT ((0)) NOT NULL,
    [ZileCASCumulate]       INT             CONSTRAINT [DF_ConcediiMedicale_ZileCASCumulate] DEFAULT ((0)) NOT NULL,
    [ValoareCAS]            DECIMAL (18, 2) CONSTRAINT [DF_ConcediiMedicale_ValoareCAS] DEFAULT ((0)) NOT NULL,
    [ZileFAMBP]             INT             CONSTRAINT [DF_ConcediiMedicale_ZileFAMBP] DEFAULT ((0)) NOT NULL,
    [ZileFAMBPCumulate]     INT             CONSTRAINT [DF_ConcediiMedicale_ZileFAMBPCumulate] DEFAULT ((0)) NOT NULL,
    [ValoareFAMBP]          DECIMAL (18, 2) CONSTRAINT [DF_ConcediiMedicale_ValoareFAMBP] DEFAULT ((0)) NOT NULL,
    [IDTipBoala]            SMALLINT        CONSTRAINT [DF_ConcediiMedicale_IDTipBoala] DEFAULT ((1)) NOT NULL,
    [CodBoalaContagioasa]   VARCHAR (20)    NULL,
    [ZileBazaCM]            INT             DEFAULT ((0)) NOT NULL,
    [CNPCopil]              VARCHAR (13)    NULL,
    [LocPrescriere]         VARCHAR (2)     NULL,
    [FaraPlataIndemnizatie] BIT             NULL,
    [AvizITM_DSP]           BIT             NULL,
    [BazaCalculataIncorect] BIT             NULL,
    CONSTRAINT [PK_ConcediiMedicale] PRIMARY KEY CLUSTERED ([IdCM] ASC),
    CONSTRAINT [FK_ConcediiMedicale_ConcediiMedicale] FOREIGN KEY ([IdCMContinuare]) REFERENCES [dbo].[ConcediiMedicale] ([IdCM]),
    CONSTRAINT [FK_ConcediiMedicale_Departamente] FOREIGN KEY ([IdDepartament]) REFERENCES [dbo].[Departamente] ([IDDepartament]),
    CONSTRAINT [FK_ConcediiMedicale_Persoane] FOREIGN KEY ([IdPersoana]) REFERENCES [dbo].[Persoane] ([IdPersoana])
);

